<%--
 *  File:    ChangePassword.jsp
 *  @Author: Shine Zheng 
 *  Date:    2001/11/15
 *
 *  Copyright (C) 2000 - 2001 Oval Technologies, Inc.
 *  All rights reserved. 
 *
 *  This software is the confidential and proprietary information of Oval 
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>     
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>
<%@ page import="com.oval.util.OvalLabel" %>
<%@ page import="com.oval.util.OvalCustomColumn" %>
<%@ page import="com.oval.util.OvalCustomMessage" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>

<% //--------------------------------------  setting logger --%>

<% 
   String strModuleName = "UPM";
   String privilegeCode = "Z0501,L501";
   String strTableName = "ovuser";
%>



<%
   Category cat = Category.getInstance("jsp.upm.ChangePassword");
   HashMap mapUser = (HashMap)session.getAttribute("userinfo");
   if(mapUser == null)
   {
      mapUser = new HashMap();
   }
   cat.info("the user info = " + mapUser);
%>
<% //--------------------------------------  include files list --%>

<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/FrmDefault.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="../../css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="../../js/FuncLib.js"></script>
</head>

<%@ include file="/inc/CheckPassword.inc" %>
<script language="JavaScript">
function changepassword()
{
    if(isEmpty(document.password.newpassword.value) || isEmpty(document.password.confirmpassword.value) || isEmpty(document.password.username.value))
  {
    alert('<%= message.getMessageDesc("VALUE_NOT_NULL",label.getLabelName("L_Password",false))%>');
    return;
  }
  else if(document.password.newpassword.value != document.password.confirmpassword.value)
  {
    alert("<%= message.getMessageDesc("DIFFERENT_PASSWORD") %>");
		return;
  }
   
  else if(document.password.newpassword.value == document.password.username.value)
  {
  	alert("<%= message.getMessageDesc("VALUE_MUST_NOTEQUAL",label.getLabelName("L_Password",false), label.getLabelName("L_UserName",false)) %>");
		return;
  }  
  else if (!checkPassword(document.password.newpassword.value))
	{
	  return;
	}
	else
	{
    isRunning = true;
    document.password.submit();
  }
}
</script>

<%
  HashMap userinfo = (HashMap)session.getAttribute("userinfo");
  if(userinfo == null)
  {
    userinfo = new HashMap();
  }
  String canupdatepassword = (String)userinfo.get("canupdatepassword");
  if(canupdatepassword == null)
  {
    canupdatepassword = "";
  }
  if(canupdatepassword.equalsIgnoreCase("y"))
  {
%>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" cellspacing="0">
  <% //--------------------------------------  page location --%>
	<%@ include file="/inc/PageLocation.inc" %>
</table>
<table width="100%" cellspacing="0" cellpadding="0" border="0">
  <tr> 
    <td valign="top"> 
      <form name="password" method="post" action="../../Dispatcher" >
        <input type="hidden" name="pagename" value="changepassword" >
        <input type="hidden" name="actionname" value="changepassword" >
        <custom:hidden name="userinfo" property="orgid" scope="session" />
        
        <input type="hidden" name="languagecode" value="<%= strLanguageCode %>" >
        
        <table width="100%" border="0" cellspacing="0">
          <tr> 
            <td class="summary_top" ></td>
          </tr>
        </table>
        <table width="100%" border="1" cellpadding="2" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center">
          <tr> 
            <td class="td-title" colspan="2"> 
              <div align="center" class="b"><%= label.getLabelName("L_ChangePassword") %></div>
            </td>
          </tr>
          <tr> 
            <td class="td-text" width="95"><%= label.getLabelName("L_CurrentUser") %><%= label.getLabelName("L_Colon") %></td>
            <td><%=JspHelper.filterNull( (String)mapUser.get("username") )%></td>
          </tr>
          <tr> 
            <td class="need"><%= label.getLabelName("L_OldPassword") %><%= label.getLabelName("L_Colon") %></td>
            <td> 
              <input type="password" name="password" size="20">
              <input type="hidden" name="username" value=<%=JspHelper.filterNull( (String)mapUser.get("username") )%>>
            </td>
          </tr>
          <tr> 
            <td class="need"><%= label.getLabelName("L_NewPassword") %><%= label.getLabelName("L_Colon") %></td>
            <td> 
              <input type="password" name="newpassword" size="20">
            </td>
          </tr>
          <tr> 
            <td class="need"><%= label.getLabelName("L_PasswordConfirm") %><%= label.getLabelName("L_Colon") %></td>
            <td> 
              <input type="password" name="confirmpassword" size="20">
            </td>
          </tr>
        </table>
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr> 
            <td class="summary_top" ></td>
          </tr>
          <tr> 
            <td class="td_center"> <a onclick="changepassword()"><custom:button type="1" label="L_Finish" imgsrc="finish.gif" border="0" style="width:60"/></a></td>
          </tr>
        </table>
      </form>
    </td>
  </tr>
</table>
</body>
<%}else{%>
<table width="100%" cellspacing="0" cellpadding="0" border="0">
  <tr>    
    <td valign="top" height="57">       
       <p><br>
            <%= message.getMessageDesc("NO_RIGHT") %></p>
            <br>
    </td>
   </tr>
   <tr>
   <td><p class="td_center">
   <a onclick="history.go(-1)"><custom:button type="1" label="L_Back" imgsrc="back.gif" border="0" style="width:60"/></a>
   </td>       
  </tr>
</table>
<%}%>
</html>


